import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author huojinhao
 * @date 2018/11/16
 */
public class Main {
    public static void main(String[] args) {
        try {
            String jdbcFile = "E:\\develop\\tomcat_cimp\\iptvcms\\webapps\\cimp\\WEB-INF\\web.xml";
            String jdbcContent = FileUtils.readFileToString(new File(jdbcFile), "utf-8");

            jdbcContent = Pattern.compile("<!-- CsrfSecurityFilter start -->.*?<!-- CsrfSecurityFilter end -->",Pattern.DOTALL).
                    matcher(jdbcContent).replaceFirst("");
            System.out.println(jdbcContent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public  static void test1() throws IOException {
        String jdbcFile = "E:\\develop\\tomcat_cimp\\iptvcms\\webapps\\cimp\\WEB-INF\\classes\\jdbc.properties";
        String jdbcContent = FileUtils.readFileToString(new File(jdbcFile), "utf-8");
        jdbcContent = Pattern.compile("bme.url.*").matcher(jdbcContent).replaceFirst("bme.url=" + "123123123123123");
        jdbcContent = Pattern.compile("bme.username.*").matcher(jdbcContent).replaceFirst("bme.username=" + "123123123123123");
        jdbcContent = Pattern.compile("vms.url.*").matcher(jdbcContent).replaceFirst("vms.url=" + "123123123123123");
        jdbcContent = Pattern.compile("vms.username.*").matcher(jdbcContent).replaceFirst("vms.username=" + "123123123123123");
        System.out.println(jdbcContent);
    }
}
